{extend name='common/container'}
{block name="content"}
<div style="margin:0 15px 15px 15px;">
    <el-card shadow="never" style="min-height:650px;" :visible.sync="show">
        <div v-if="search_visible" id="search" class="search">
            <el-form ref="form" size="small" :model="searchData" inline>
                <el-form-item label="用户ID/地址">
                    <el-input id="mid" v-model="searchData.mid"  style="width:150px;" placeholder="请输入用户ID、地址"></el-input>
                </el-form-item>
                <el-form-item label="币种">
                    <el-select   style="width:100%" v-model="searchData.currency" filterable clearable placeholder="请选择币种">
                        <el-option v-for="(item,i) in currency_list" :key="i" :label="item.name" :value="item.id"></el-option>
                    </el-select>
                </el-form-item>
                <search-tool :search_data.sync="searchData" :is_clear.sync="is_clear" @refesh_list="index"></search-tool>
            </el-form>
        </div>
        <div class="btn-group" style="margin-top:10px;margin-bottom:10px;">
            <div>
                <el-button v-for="item in button_group" :key="item.access" v-if="checkPermission(item.access,'{:implode(',',session('admin.access'))}','{:session('admin.role_id')}',[1])" :disabled="$data[item.disabled]" :type="item.color" size="mini" :icon="item.icon" @click="fn(item.clickname)">
                    <span v-if="item.batch" v-text="$data['batchUpdateStatus']?'批量保存':'批量编辑'"></span>
                    <span v-else v-text="item.name"></span>
                </el-button>
            </div>
            <div><table-tool :search_visible.sync="search_visible"  @refesh_list="index"></table-tool></div>
        </div>
        <el-table :row-class-name="rowClass" @selection-change="selection"  @row-click="handleRowClick"  row-key="id"  :header-cell-style="{ background: '#eef1f6', color: '#606266' }" @sort-change='sortChange' v-loading="loading"  ref="multipleTable" border class="eltable" :data="list" :summary-method="getSummaries" show-summary style="width: 100%">
            <el-table-column align="center" type="selection" width="42"></el-table-column>
            <el-table-column align="center" type = '' property="id"  label="编号"  width="70">
            </el-table-column>
            <el-table-column align="center"  property="username" label="发起转账用户" >
            </el-table-column>
            <el-table-column align="center"  property="receive_username"  label="收款用户">
            </el-table-column>
            <el-table-column align="center" sortable property="currency"  label="币种"  width="100">
            </el-table-column>
            <el-table-column align="center" sortable property="money" label="转账数量" width="100">
            </el-table-column>
            <el-table-column align="center" sortable property="charge_money" label="手续费" width="100">
            </el-table-column>
            <el-table-column align="center"  property="remarks" label="备注" width="100">
            </el-table-column>
            <el-table-column align="center"  property="add_time" label="发起时间">
            </el-table-column>
            <el-table-column :fixed="ismobile()?false:'right'" label="操作" align="center" width="180">
                <template slot-scope="scope">
                    <div v-if="scope.row.id">
                        <!--                        <el-button v-if="checkPermission('/admin/Draw/edit.html','{:implode(",",session("admin.access"))}','{:session("admin.role_id")}',[1])" size="mini" icon="el-icon-edit" type="primary" @click="update(scope.row)" >修改</el-button>-->
                        <!--                        <el-button v-if="checkPermission('/admin/Finance/delete_capital.html','{:implode(",",session("admin.access"))}','{:session("admin.role_id")}',[1])" size="mini" icon="el-icon-delete" type="danger" @click="del(scope.row)" >删除</el-button>-->
                    </div>
                </template>
            </el-table-column>
        </el-table>
        <Page :total="page_data.total" :page.sync="page_data.page" :limit.sync="page_data.limit" @pagination="index" />
    </el-card>

    <!--添加-->
    <Add :show.sync="dialog.addDialogStatus" size="small" @refesh_list="index"></Add>
    <!--修改-->
    <Update :info="updateInfo" :show.sync="dialog.updateDialogStatus" size="small" @refesh_list="index"></Update>
    <!--查看详情-->
    <Detail :info="detailInfo" :show.sync="dialog.detailDialogStatus" size="small" @refesh_list="index"></Detail>

</div>

{/block}
{block name="script"}
<script src="__PUBLIC__/assets/js/app.js"></script>
<script src="__PUBLIC__/assets/libs/xlsx/xlsx.core.min.js"></script>
<script>
    new Vue({
        el: '#app',
        components:{
        },
        props: {
            show: {
                type: Boolean,
                default: false
            },
            size: {
                type: String,
                default: 'small'
            },
        },
        data: function() {
            return {
                dialog: {
                    addDialogStatus : false,
                    updateDialogStatus : false,
                },
                searchData:{},
                button_group:[
                    {name:'导出',color:'warning',access:'/admin/Finance/dumpdata_transfer.html',icon:'el-icon-download',disabled:'',clickname:'dumpdata'},
                ],
                dumpshow:false,
                percentage:0,
                dumppage:1,
                loading: false,
                level_list:[],
                currency_list:[{'id':1,'name':'USDT'},{'id':5,'name':'ADC'}],
                search_visible:true,
                page_data: {
                limit: 20,
                    page: 1,
                    total:20,
                },

            }
        },
        watch:{
        },
        methods:{
            index(){
                let param = {limit:this.page_data.limit,page:this.page_data.page,order:this.order,sort:this.sort}
                Object.assign(param, this.searchData,this.urlobj)
                this.loading = true
                axios.post(base_url + '/Finance/transfer_list',param).then(res => {
                    if(res.data.status == 200){
                        this.list = res.data.data.data
                        this.page_data.total = res.data.data.total
                        this.sum_amount = res.data.sum_amount
                        this.loading = false
                    }else{
                        this.$message.error(res.data.msg);
                    }
                })
                // axios.post(base_url + '/MemberLevel/getList').then(res => {
                //     if(res.data.status == 200){
                //         this.level_list = res.data.data
                //     }
                // })
            },

            del(row){
                this.$confirm('确定操作吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    let ids = row.id ? row.id : this.ids.join(',')
                    axios.post(base_url + '/Finance/delete_transfer',{id:ids}).then(res => {
                        if(res.data.status == 200){
                            this.$message({message: res.data.msg, type: 'success'})
                            this.index()
                        }else{
                            this.$message.error(res.data.msg)
                        }
                    })
                }).catch(() => {})
            },
            dumpdata(){
                this.$confirm('确定操作吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.dumpshow = true
                    this.confirmdumpdata()
                }).catch(() => {})
            },
            confirmdumpdata(){
                let query = {page:this.dumppage,order:this.order,sort:this.sort}
                axios.post(base_url + '/Finance/dumpdata_transfer',query).then(res => {
                    if(res.data.state == 'ok'){
                        this.percentage = res.data.percentage
                        this.dumppage = this.dumppage + 1
                        this.confirmdumpdata()
                    }else{
                        this.dumpshow = false
                        location.href = base_url + '/Finance/dumpdata_transfer?state=ok&'+param(query)
                    }
                })
            },
            fn(method){
                this[method](this.ids)
            },
        },
        mounted(){
            this.index()
        },
    })
</script>
{/block}
